// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class INVOICE_PROCESSING_RESULTS_INFO_EHC_E10 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("7 IPR",7)]
  	    [HL7Field(HL7Version.v26, 7, HL7Repeat.False, HL7Required.True,"IPR")]
	    public IPR IPR {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("8 NTE",8)]
  	    [HL7Field(HL7Version.v26, 8, HL7Repeat.True, HL7Required.False,"NTE")]
	    public NTE[] NTE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("9 PYE",9)]
  	    [HL7Field(HL7Version.v26, 9, HL7Repeat.False, HL7Required.True,"PYE")]
	    public PYE PYE {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("10 IN1",10)]
  	    [HL7Field(HL7Version.v26, 10, HL7Repeat.False, HL7Required.True,"IN1")]
	    public IN1 IN1 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("11 IN2",11)]
  	    [HL7Field(HL7Version.v26, 11, HL7Repeat.False, HL7Required.False,"IN2")]
	    public IN2 IN2 {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("12 IVC",12)]
  	    [HL7Field(HL7Version.v26, 12, HL7Repeat.False, HL7Required.True,"IVC")]
	    public IVC IVC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("13 PRODUCT_SERVICE_SECTION",13)]
  	    [HL7Field(HL7Version.v26, 13, HL7Repeat.True, HL7Required.True,"PRODUCT_SERVICE_SECTION_EHC_E10")]
	    public PRODUCT_SERVICE_SECTION_EHC_E10[] PRODUCT_SERVICE_SECTION {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			IPR = PopSegmentParseAndCheckRequired<IPR>(availableData, options, "IPR");
			NTE = PopSegmentParseAndCheckRequiredArray<NTE>(availableData, options, "NTE");
			PYE = PopSegmentParseAndCheckRequired<PYE>(availableData, options, "PYE");
			IN1 = PopSegmentParseAndCheckRequired<IN1>(availableData, options, "IN1");
			IN2 = PopSegmentParseAndCheckRequired<IN2>(availableData, options, "IN2");
			IVC = PopSegmentParseAndCheckRequired<IVC>(availableData, options, "IVC");
			PRODUCT_SERVICE_SECTION = ProcessGroupArray<PRODUCT_SERVICE_SECTION_EHC_E10>(availableData, options, "PRODUCT_SERVICE_SECTION");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isIPR = availableData.StartsWith("IPR", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IPR", options.Version) || isIPR) {
				return isIPR;
			}
			bool isNTE = availableData.StartsWith("NTE", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("NTE", options.Version) || isNTE) {
				return isNTE;
			}
			bool isPYE = availableData.StartsWith("PYE", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("PYE", options.Version) || isPYE) {
				return isPYE;
			}
			bool isIN1 = availableData.StartsWith("IN1", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IN1", options.Version) || isIN1) {
				return isIN1;
			}
			bool isIN2 = availableData.StartsWith("IN2", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IN2", options.Version) || isIN2) {
				return isIN2;
			}
			bool isIVC = availableData.StartsWith("IVC", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("IVC", options.Version) || isIVC) {
				return isIVC;
			}
			PRODUCT_SERVICE_SECTION_EHC_E10 testPRODUCT_SERVICE_SECTION_EHC_E10 = new PRODUCT_SERVICE_SECTION_EHC_E10();
			bool grpCCPRODUCT_SERVICE_SECTION_EHC_E10 = (testPRODUCT_SERVICE_SECTION_EHC_E10.CanConsume(availableData, options));
			if (IsRequired("PRODUCT_SERVICE_SECTION", options.Version) || grpCCPRODUCT_SERVICE_SECTION_EHC_E10) {
				return grpCCPRODUCT_SERVICE_SECTION_EHC_E10;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "INVOICE_PROCESSING_RESULTS_INFO";
			}
        }

        static INVOICE_PROCESSING_RESULTS_INFO_EHC_E10() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(INVOICE_PROCESSING_RESULTS_INFO_EHC_E10));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (IPR != null) {
			string segmentValue = IPR.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (NTE != null && NTE.Length > 0) {
			for (int i = 0; i < NTE.Length; i++) {
				string segmentValue = NTE[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
		 if (PYE != null) {
			string segmentValue = PYE.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (IN1 != null) {
			string segmentValue = IN1.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (IN2 != null) {
			string segmentValue = IN2.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (IVC != null) {
			string segmentValue = IVC.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (PRODUCT_SERVICE_SECTION != null && PRODUCT_SERVICE_SECTION.Length > 0) {
			for (int i = 0; i < PRODUCT_SERVICE_SECTION.Length; i++) {
				string segmentValue = PRODUCT_SERVICE_SECTION[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

